//
//  ADLViewController.m
//  dangxiao_new
//
//  Created by 段帅 on 16/9/29.
//  Copyright © 2016年 newfuture. All rights reserved.
//

#import "ADLViewController.h"

#import "dangXiaoHeader_tool.h"
#import "SCUIToolHeader.h"
@interface ADLViewController ()<UIWebViewDelegate>

@end

@implementation ADLViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = _model.title;
    
    self.navbar.backgroundColor = Color_Main;
    
    [self addWebView];
    
    // Do any additional setup after loading the view.
}

- (void)addWebView{
    
    
   self.automaticallyAdjustsScrollViewInsets = YES;
    
    //1、创建UIWebView：
    
    //   CGRect bounds = [[UIScreen mainScreen]applicationFrame];
    UIWebView* webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 64, SIZEWIDTH, SIZEHEIGHT-64)];
    webView.backgroundColor = [UIColor whiteColor];
    //    self.view.backgroundColor = [UIColor greenColor];
    //2、设置属性：
    
    webView.scalesPageToFit = YES;//自动对页面进行缩放以适应屏幕
    //   webView.detectsPhoneNumbers = YES;//自动检测网页上的电话号码，单击可以拨打
    webView.delegate = self;
    //3、显示网页视图UIWebView：
    
    [self.view addSubview:webView];
    
    // 4、加载内容
    
    NSURL* url = [NSURL URLWithString:self.url];//创建URL
    NSURLRequest* request = [NSURLRequest requestWithURL:url];//创建NSURLRequest
    [webView loadRequest:request];//加载
    
    
}

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    NSLog(@"%@",request.URL.absoluteString);
    if ([request.URL.absoluteString isEqualToString:@"weixin://"]) {
        if ([[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"weixin://"]]) {
            NSLog(@"有微信");
        }else {
            ALERT_FAIL(@"没有安装微信")
        }
        
       
            ;
              
        return NO;
    }
    
    
    
    return YES;
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
